package com.bls.cate.ui.activity.login;

import android.widget.EditText;

import com.blankj.utilcode.util.RegexUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.bls.cate.constant.Constant;
import com.bls.cate.mvp.BasePresenterImpl;

public class LoginPresenter extends BasePresenterImpl<LoginContract.View> implements LoginContract.Presenter {

    @Override
    public void onLogin(EditText etUsername, EditText etPassword) {
        String username = etUsername.getText().toString().trim();
        String pwd = etPassword.getText().toString().trim();
        if (!(RegexUtils.isMobileSimple(username) || RegexUtils.isEmail(username)))
            ToastUtils.showShort("请填写手机号或邮箱");
        else if (pwd.length() < Constant.PASSWORD_LENGTH)
            ToastUtils.showShort("密码长度不小于".concat(String.valueOf(Constant.PASSWORD_LENGTH)).concat("位"));
        else mView.onViewLogin(username, pwd);
    }
}
